<template>
  <div class="publish-container">
    <!--面包导航区域  -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/login' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path:'/bannerManage'}">招聘管理</el-breadcrumb-item>
      <el-breadcrumb-item>添加招聘信息</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片 -->
    <el-card class="box-card">
      <!-- 标题 -->
      <div slot="header" class="clearfix">
        <span>发布招聘</span>
      </div>
      <!-- 表单 -->
      <el-form ref="addBannerRef" :model="contact" :rules="addFormRules" label-width="80px" label-position="left" >
        <!-- 标题 作者区域 -->

            <el-form-item label="标题" prop="title">
              <el-input v-model="contact.title"  show-word-limit style="width:600px;"></el-input>
            </el-form-item>
            <el-form-item label="招聘人数">
              <el-input v-model="contact.num" placeholder="必须是数字"  show-word-limit style="width:600px;"></el-input>
            </el-form-item>
            <el-form-item label="联系邮箱">
              <el-input v-model="contact.email"  show-word-limit style="width:600px;"></el-input>
            </el-form-item>

            <el-form-item label="工作职责" >
              <el-input type="textarea"  v-model="contact.content1"></el-input>
            </el-form-item>
            <el-form-item label="职务要求">
              <el-input type="textarea"  v-model="contact.content2"></el-input>
            </el-form-item>


        <el-form-item>
          <el-button  @click="$router.go(-1)">返回</el-button>
          <el-button type="primary" @click="onPublish(false)">添加</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>

import {postAddContact} from '@/api/contact.js'

export default {
  name:'AddContact',
  data() {
    return {
      //添加招聘参数
      contact: {
        
      },
      addFormRules:{
        title:[
          {required: true, message: '请输入用户名称', trigger: 'blur'}
        ]
      },
    };
  },
  computed: {},
  methods: {
    //添加招聘
    async onPublish() {
      this.$refs.addBannerRef.validate(async (valid) =>{
        if(!valid) return
        console.log(this.contact)
        const { data: res } = await postAddContact(this.contact);
        if (res.meta.status !== 200) return this.$message.error("添加招聘失败");
        this.$message.success("添加招聘成功");
        // console.log(this.$router)
        this.$router.push("/contactManage");
      })
    },

  },
  created() {},
  mounted() {},
};
</script>

<style  scoped>

</style>